<?php

App::uses('AppModel', 'Model');

class Setting extends Model {

	const KEY_ACTIVE_ACCOUNT = 'active_account';

	public function getValue($name) {
		$setting = $this->findByName($name);
		return isset($setting['Setting']['value']) ? $setting['Setting']['value'] : null;
	}
	
	public function setValue($name, $value) {
		$setting = $this->findByName($name);
		if (empty($setting)) {
			return $this->save(array('name' => $name, 'value' => $value));
		}
		return $this->updateAll(array('value' => $value), array('name' => $name));
	}

}
